package ch.simas.cdi;

import java.io.Serializable;
import javax.enterprise.context.Conversation;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Inject;
import javax.inject.Named;

/**
 *
 * @author Simon
 */
@ConversationScoped
@Named
public class ConversationBean implements Serializable {

    @Inject
    private Conversation conversation;
    
    private String state;

    public String start() {
        conversation.begin();
        state = "Conversation running: " + conversation.getId();
                
        return "conversation.xhtml";
    }

    public void stop() {
        conversation.end();
        state = "Conversation ended";
    }
    
    public String getState() {
        return state;
    }
}
